#include<bits/stdc++.h>
using namespace std;
int n,m,L,V,t;
bool vis[1000005],visl[1000005];
int a[100005],v[100005],d[100005],b[100005];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--){
		memset(visl,0,sizeof(visl));
		memset(vis,0,sizeof(vis));
		cin>>n>>m>>L>>V;
		for(int i=1;i<=n;i++){
			cin>>d[i]>>a[i]>>v[i];
		}
		for(int i=1;i<=m;i++){
			cin>>b[i];
			vis[b[i]]=1;
		}
		int cnt=0,ans=0;
		for(int i=1;i<=n;i++){
			if(v[i]==0){
				if(a[i]>V){
					bool f=0,f1=0;
					for(int j=d[i];j<=L;j++){
						if(vis[j]){
							if(!f){
								f=1;
								cnt++;
							}
							if(!visl[j]){
								visl[j]=1;
								f1=1;
								ans++;
							}
						}
					}
					if(f1) ans--;
				}
				continue;
			}
			if(v[i]<0){
				int x=d[i]+(1.0*V*V-1.0*a[i]*a[i])/2/v[i];
				bool f=0,f1=0;
				for(int j=d[i];j<=x;j++){
					if(vis[j]){
						if(!f){
							f=1;
							cnt++;
						}
						if(!visl[j]){
							visl[j]=1;
							ans++;
							f1=1;
						}
					}
				}
				if(f1) ans--;
			}else{
				int x=d[i]+ceil((1.0*V*V-1.0*a[i]*a[i])/2/v[i]);
				bool f=0,f1=0;
				for(int j=x;j<=L;j++){
					if(vis[j]){
						if(!f){
							f=1;
							cnt++;
						}
						if(!visl[j]){
							visl[j]=1;
							ans++;
							f1=1;
						}
					}
				}
				if(f1) ans--;
			}
			//cout<<i<<" "<<x<<"\n";
		}
		cout<<cnt<<" "<<ans<<"\n";
	}
	return 0;
}

